package com.kgc.ssm.mapper;

import com.kgc.ssm.entity.ContractApply;
import com.kgc.ssm.entity.ContractApplyExample;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;

import java.util.List;
import java.util.Map;

public interface ContractApplyMapper {
    long countByExample(ContractApplyExample example);

    int deleteByExample(ContractApplyExample example);

    int deleteByPrimaryKey(Long id);

    int insert(ContractApply row);

    int insertSelective(ContractApply row);

    List<ContractApply> selectByExampleWithRowbounds(ContractApplyExample example, RowBounds rowBounds);

    List<ContractApply> selectByExample(ContractApplyExample example);

    ContractApply selectByPrimaryKey(Long id);

    int updateByExampleSelective(@Param("row") ContractApply row, @Param("example") ContractApplyExample example);

    int updateByExample(@Param("row") ContractApply row, @Param("example") ContractApplyExample example);

    int updateByPrimaryKeySelective(ContractApply row);

    int updateByPrimaryKey(ContractApply row);

    @Select("select * from CONTRACT_APPLY c,ENQUIRE e " +
            "where c.ENQUIRE_ID = e.ID ")
    List<Map<String,Object>> selectAlAppEnquire();


    @Select("SELECT * " + "FROM ID_MAPPING im " + "  JOIN CONTRACT_APPLY ca " + "    ON ca.id = im.CONT_APP_ID " + "  JOIN CONTRACT c " + "    ON c.ID = im.CONT_ID " + "  JOIN CONTRACT_DETAIL cd " + "    ON c.ID = cd.CONT_ID " + "  JOIN STOCK s " + "    ON s.ID = im.STOCK_ID " + "  JOIN SUPPLIER su " + "    ON su.SUPPLIER_NUM = c.SUPPLIER_NUM " + "WHERE im.CONT_APP_ID = #{id}")
    List<Map<String,Object>> findById(@Param("id") Integer id);
}